import 'package:http/http.dart' as http;
void main() {
 print("main start");
 getWebsiteStatus();
 print("main end");
}

Future getWebsiteStatus() async{
  print("开始获取网站的状态");
  int status = await getHttp();
  if(status == 200){
    print("网站可用");
  }else{
    print("网站不可用");
  }
}

Future<int> getHttp() async {
  try{
    final result = await http.get(Uri.http('www.doubibiji.com', '/', {})).timeout(Duration(seconds: 5));
    return result.statusCode;
  }catch(e){
    print("请求出错: $e");
    return -1;
  }
}